import { createI18n } from 'vue-i18n';

const messages = {
  en: {
    app: {
      theme: 'Theme',
      system: 'System',
      light: 'Light',
      dark: 'Dark',
      settings: 'Settings',
      settings_title: 'WaCoder Settings',
      settings_general: 'General',
      settings_appearance: 'Appearance',
      settings_hotkeys: 'Hotkeys',
      settings_models: 'Models',
      settings_history: 'History',
      language_label: 'Language',
      theme_label: 'Theme',
      toggle_ai: 'Toggle AI Pane',
      toggle_main: 'Toggle Main Sidebar',
      toggle_bottom: 'Toggle Bottom Panel',
      bottom_terminal: 'Terminal',
      bottom_problems: 'Problems',
      bottom_output: 'Output',
      window_minimize: 'Minimize',
      window_maximize: 'Maximize',
      window_restore: 'Restore',
      window_close: 'Close',
      refresh: 'Refresh',
      model_config: 'Model Config',
      model_unselected: 'Unselected',
      input_placeholder: 'Type a message and press Enter',
      close: 'Close',
      language: 'Language',
      settings_user: 'User',
      settings_workspace: 'Workspace',
      settings_editor: 'Editor',
      editor_read_only: 'Read Only',
      split_editor: 'Split Editor',
      preview: 'Preview',
      no_file: 'No file',
      editor_font_size: 'Font Size',
      editor_word_wrap: 'Word Wrap',
      editor_minimap: 'Minimap',
      editor_render_whitespace: 'Render Whitespace',
      editor_tab_size: 'Tab Size',
      editor_insert_spaces: 'Insert Spaces',
      editor_read_only: 'Read Only',
      wrap_off: 'Off',
      wrap_on: 'On',
      wrap_bounded: 'Bounded',
      wrap_column: 'Column',
      ws_none: 'None',
      ws_selection: 'Selection',
      ws_all: 'All',
      no_matches: 'No matches',
      history_max_files_per_project: 'Max Files Per Project',
      history_max_entries_per_file: 'Max Entries Per File',
      history_max_age_days: 'Max Age (Days)',
      history_cleanup_button: 'Cleanup History Now',
      history_cleanup_running: 'Cleaning up...',
      history_cleanup_success: 'Cleanup completed successfully',
      history_cleanup_error: 'Cleanup failed',
      history_cleanup_description: 'Automatically clean up old history records based on the above settings. Records exceeding the limits will be removed to optimize performance.',
      default: 'Default',
      days: 'days',
      history_cleanup_description_1: 'History records are automatically cleaned up when saving files',
      history_cleanup_description_2: 'Records exceeding the set limits or time will be automatically deleted',
      history_cleanup_description_3: 'Cleanup strategy is similar to VS Code, keeping the latest records',
    },
    problems: {
      copy_message: '复制消息',
      copy_file_path: '复制文件路径',
      copy_all_messages: '复制当前路径下的全部问题',
    },
    explorer: {
      new_file_placeholder: 'New File',
      new_folder_placeholder: 'New Folder',
      rename_placeholder: 'Rename',
      prompt_file_name: 'File name',
      prompt_folder_name: 'Folder name',
      prompt_rename_to: 'Rename to',
      confirm_delete_one: 'Are you sure you want to delete "{name}"? This action cannot be undone.',
      confirm_delete_many: 'Are you sure you want to delete {count} items? This action cannot be undone.',
      expand: 'Expand',
      collapse: 'Collapse',
    },
    menus: {
      title: 'Menus',
      menubar: 'Menubar',
      add_menu: 'Add Menu',
      add_item: 'Add Item',
      label: 'Label',
      action: 'Action',
      accelerator: 'Accelerator',
      visible: 'Visible',
      enabled: 'Enabled',
      submenu: 'Submenu',
      remove: 'Remove',
      save: 'Save',
      saving: 'Saving...',
      saved: 'Saved',
      err_invalid: 'Invalid shortcut',
      err_duplicate: 'Duplicate shortcut in menubar',
      err_conflict: 'Conflicts with global hotkeys',
      err_fix: 'Please fix highlighted fields.',
    },
    menu: {
      file: 'File', edit: 'Edit', selection: 'Selection', view: 'View', go: 'Go', run: 'Run', terminal: 'Terminal', help: 'Help',
      explorer: 'Explorer', search: 'Search', extensions: 'Extensions',
      new_file: 'New File', open: 'Open...', open_file: 'Open File...', open_folder: 'Open Folder...', open_recent: 'Open Recent Files', save: 'Save', exit: 'Exit',
      save_as: 'Save As...', save_all: 'Save All', close_editor: 'Close Editor', close_window: 'Close Window', reopen_closed: 'Reopen Closed Editor', preferences: 'Preferences',
      close_others: 'Close Others', close_to_right: 'Close to Right',
      recent_files: 'Recent Files', recent_folders: 'Recent Folders', recent_empty: 'No Recent',
      reveal_in_explorer: 'Reveal in Explorer', open_in_terminal: 'Open in Integrated Terminal', new_folder: 'New Folder', rename: 'Rename', delete: 'Delete',
      toggle_sidebar: 'Toggle Sidebar', toggle_panel: 'Toggle Panel', toggle_ai: 'Toggle AI', about: 'About',
    },
    model: {
      saved_keys: 'Saved Keys',
      new: '(New)',
      delete: 'Delete',
      key_name: 'Key Name',
      base_url: 'Base URL',
      api_key: 'API Key',
      model: 'Model',
      default_temperature: 'Default Temperature (0-2)',
      default_max_tokens: 'Default Max Tokens',
      custom_headers: 'Custom Headers',
      header_name: 'Header Name',
      header_value: 'Header Value',
      add: 'Add',
      save: 'Save',
      saving: 'Saving...',
      saved: 'Saved',
      require_key_name: 'Please enter a key name',
    },
    chat: {
      title: 'Chat',
      select_model_warning: 'Please configure and select a model key first',
      me: 'Me', system: 'SYS', ai: 'AI',
      scroll_to_bottom: 'Scroll to bottom',
    },

    hotkeys: {
      title: 'Hotkeys',
      command: 'Command',
      keybinding: 'Keybinding',
      reset_row: 'Reset',
      save: 'Save',
      saving: 'Saving...',
      reset: 'Reset',
      saved: 'Saved',
      placeholder: 'e.g. mod+alt+i',
      toggle_ai: 'Toggle AI Pane',
      toggle_main: 'Toggle Main Sidebar',
      open_settings: 'Open Settings',
      refresh_ai: 'Refresh',
      focus_input: 'Focus Input',
      open_devtools: 'Open Devtools',
    },
    search: {
      search: 'Search',
      replace: 'Replace',
      match_case: 'Match Case',
      whole_word: 'Whole Word',
      regex: 'Use Regex',
      include: 'Include Files',
      include_hint: 'Comma-separated globs, e.g. src/**, *.ts',
      exclude: 'Exclude Files',
      exclude_hint: 'Comma-separated globs, e.g. node_modules, dist',
      search_placeholder: 'Search',
      replace_placeholder: 'Replace',
      toggle_replace: 'Show Replace',
      hide_replace: 'Hide Replace',
      stop: 'Stop',
      results_summary: '{total} results in {files} files',
      no_results: 'No results',
      searching_progress: 'Searching {current}/{total} files...',
      replace_all: 'Replace All',
      searching: 'Searching...',
      expand_all: 'Expand All',
      collapse_all: 'Collapse All',
      clear_results: 'Clear Results',
      replace_done: 'Replaced {matches} occurrences in {files} files'
    },
    problems: {
      copy_message: 'Copy Message',
      copy_file_path: 'Copy File Path',
      copy_all_messages: 'Copy All Messages in Current Path',
    },
    sidebar: {
      timeline: 'Timeline',
      folder: 'Folder',
      no_folder_opened: 'No Folder Opened'
    },
    extensions: {
      installed: 'Installed',
      footer: 'Plugin System Active'
    },
    timeline: {
      title: 'Timeline',
      loading: 'Loading...',
      no_entries: 'No timeline entries',
      open: 'Open',
      restore: 'Restore to this version',
      diff: 'Compare with current',
      compare: 'Compare with current'
    },
    editor: {
      noFilesOpen: 'No files open',
      openFileToStart: 'Open a file to start editing',
      newTab: 'New Tab',
      splitHorizontal: 'Split Horizontal',
      splitVertical: 'Split Vertical'
    },
    theme: {
      basic_settings: 'Basic Settings',
      preset_themes: 'Preset Themes',
      custom_colors: 'Custom Colors',
      interface_config: 'Interface Configuration',
      file_icons: 'File Icons',
      product_icons: 'Product Icons',
      accent_color: 'Accent Color',
      panel_bg: 'Panel Background',
      app_bg: 'App Background',
      font_size: 'Font Size',
      font_size_small: 'Small',
      font_size_medium: 'Medium',
      font_size_large: 'Large',
      ui_density: 'UI Density',
      density_compact: 'Compact',
      density_comfortable: 'Comfortable',
      density_spacious: 'Spacious',
      border_radius: 'Border Radius',
      radius_none: 'None',
      radius_small: 'Small',
      radius_medium: 'Medium',
      radius_large: 'Large',
      animations: 'Animations',
      reset_defaults: 'Reset to Defaults'
    },
  },
  zh: {
    app: {
      theme: '主题',
      system: '跟随系统',
      light: '浅色',
      dark: '深色',
      settings: '配置',
      settings_title: 'WaCoder 设置',
      settings_general: '通用',
      settings_appearance: '外观',
      settings_hotkeys: '快捷键',
      settings_models: '模型',
      settings_history: '历史记录',
      language_label: '语言',
      theme_label: '主题',
      toggle_ai: '切换 AI 面板',
      toggle_main: '切换主侧边栏',
      toggle_bottom: '切换底部面板',
      bottom_terminal: '终端',
      bottom_problems: '问题',
      bottom_output: '输出',
      window_minimize: '最小化',
      window_maximize: '最大化',
      window_restore: '还原',
      window_close: '关闭',
      refresh: '刷新',
      model_config: '模型配置',
      model_unselected: '未选择',
      input_placeholder: '输入消息，回车发送',
      close: '关闭',
      language: '语言',
      settings_user: '用户',
      settings_workspace: '工作区',
      settings_editor: '编辑器',
      editor_read_only: '只读',
      split_editor: '拆分编辑器',
      preview: '预览',
      no_file: '无文件',
      editor_font_size: '字号',
      editor_word_wrap: '自动换行',
      editor_minimap: '迷你地图',
      editor_render_whitespace: '显示空白字符',
      editor_tab_size: 'Tab 宽度',
      editor_insert_spaces: '使用空格缩进',
      editor_read_only: '只读',
      wrap_off: '关闭',
      wrap_on: '开启',
      wrap_bounded: '边界',
      wrap_column: '列',
      ws_none: '不显示',
      ws_selection: '选区',
      ws_all: '全部',
      no_matches: '无匹配结果',
      history_max_files_per_project: '单个项目最大记录数',
      history_max_entries_per_file: '单个文件最大记录数',
      history_max_age_days: '记录保存天数',
      history_cleanup_button: '立即清理历史记录',
      history_cleanup_running: '清理中...',
      history_cleanup_success: '清理完成',
      history_cleanup_error: '清理失败',
      history_cleanup_description: '根据上述设置自动清理过期的历史记录。超出限制的记录将被删除以优化性能。',
      default: '默认',
      days: '天',
      history_cleanup_description_1: '历史记录会在每次保存文件时自动清理',
      history_cleanup_description_2: '超过设定数量或时间的记录会被自动删除',
      history_cleanup_description_3: '清理策略类似 VS Code，保留最新的记录',
    },
    explorer: {
      new_file_placeholder: '新建文件',
      new_folder_placeholder: '新建文件夹',
      rename_placeholder: '重命名',
      prompt_file_name: '文件名',
      prompt_folder_name: '文件夹名',
      prompt_rename_to: '重命名为',
      confirm_delete_one: '确定删除“{name}”吗？此操作不可撤销。',
      confirm_delete_many: '确定删除 {count} 个项目吗？此操作不可撤销。',
      expand: '展开',
      collapse: '折叠',
    },
    menus: {
      title: '菜单',
      menubar: '菜单栏',
      add_menu: '添加菜单',
      add_item: '添加项',
      label: '标题',
      action: '动作',
      accelerator: '快捷键',
      visible: '可见',
      enabled: '启用',
      submenu: '子菜单',
      remove: '删除',
      save: '保存',
      saving: '保存中...',
      saved: '已保存',
      err_invalid: '快捷键不合法',
      err_duplicate: '菜单内快捷键重复',
      err_conflict: '与全局快捷键冲突',
      err_fix: '请修复标红字段。',
    },
    menu: {
      file: '文件', edit: '编辑', selection: '选择', view: '查看', go: '转到', run: '运行', terminal: '终端', help: '帮助',
      explorer: '资源管理器', search: '搜索', extensions: '扩展',
      new_file: '新建文件', open: '打开...', open_file: '打开文件...', open_folder: '打开文件夹...', open_recent: '打开最近的文件', save: '保存', exit: '退出',
      save_as: '另存为...', save_all: '全部保存', close_editor: '关闭编辑器', close_window: '关闭窗口', reopen_closed: '重新打开已关闭的编辑器', preferences: '首选项',
      close_others: '关闭其他',
      close_to_right: '关闭右侧',
      recent_files: '最近文件', recent_folders: '最近文件夹',
      recent_empty: '无最近记录',
      reveal_in_explorer: '在资源管理器中显示', open_in_terminal: '在集成终端中打开', new_folder: '新建文件夹', rename: '重命名', delete: '删除',
      toggle_sidebar: '切换侧边栏', toggle_panel: '切换面板', toggle_ai: '切换 AI', about: '关于',
    },
    model: {
      saved_keys: '已保存键值',
      new: '（新建）',
      delete: '删除',
      key_name: '键名',
      base_url: 'Base URL',
      api_key: 'API Key',
      model: '模型',
      default_temperature: '默认温度 (0-2)',
      default_max_tokens: '默认最大 Token',
      custom_headers: '自定义 Headers',
      header_name: 'Header 名称',
      header_value: 'Header 值',
      add: '添加',
      save: '保存',
      saving: '保存中...',
      saved: '已保存',
      require_key_name: '请填写模型键名',
    },
    chat: {
      title: '聊天',
      select_model_warning: '请先在右侧配置并选择模型键',
      me: '我', system: '系', ai: 'AI',
      scroll_to_bottom: '滚动到底部',
    },

    hotkeys: {
      title: '快捷键',
      command: '命令',
      keybinding: '快捷键',
      reset_row: '重置',
      save: '保存',
      saving: '保存中...',
      reset: '重置',
      saved: '已保存',
      placeholder: '例如 mod+alt+i',
      toggle_ai: '切换 AI 面板',
      toggle_main: '切换主侧边栏',
      open_settings: '打开设置',
      refresh_ai: '刷新',
      focus_input: '聚焦输入',
      open_devtools: '打开开发者工具',
    },
    search: {
      search: '搜索',
      replace: '替换',
      match_case: '区分大小写',
      whole_word: '匹配整词',
      regex: '使用正则',
      include: '包含文件',
      include_hint: '逗号分隔的通配符，例如 src/**、*.ts',
      exclude: '排除文件',
      exclude_hint: '逗号分隔的通配符，例如 node_modules、dist',
      search_placeholder: '搜索',
      replace_placeholder: '替换',
      toggle_replace: '展开替换',
      hide_replace: '隐藏替换',
      stop: '停止',
      results_summary: '{total} 个结果，来自 {files} 个文件',
      no_results: '无结果',
      searching_progress: '正在搜索 {current}/{total} 个文件...',
      replace_all: '替换所有',
      searching: '正在搜索...',
      expand_all: '展开所有',
      collapse_all: '折叠所有',
      clear_results: '清除结果',
      replace_done: '已在 {files} 个文件中替换 {matches} 处'
    },
    sidebar: {
      timeline: '时间线',
      folder: '文件夹',
      no_folder_opened: '未打开文件夹'
    },
    extensions: {
      installed: '已安装',
      footer: '插件系统已启用'
    },
    timeline: {
      title: '时间线',
      loading: '加载中...',
      no_entries: '无时间线条目',
      open: '打开',
      restore: '还原到此版本',
      diff: '与当前版本比较',
      compare: '与当前版本比较'
    },
    editor: {
      noFilesOpen: '未打开文件',
      openFileToStart: '打开文件开始编辑',
      newTab: '新建标签页',
      splitHorizontal: '水平分割',
      splitVertical: '垂直分割'
    },
    theme: {
      basic_settings: '基本设置',
      preset_themes: '预设主题',
      custom_colors: '自定义颜色',
      interface_config: '界面配置',
      file_icons: '文件图标',
      product_icons: '产品图标',
      accent_color: '强调色',
      panel_bg: '面板背景',
      app_bg: '应用背景',
      font_size: '字体大小',
      font_size_small: '小',
      font_size_medium: '中',
      font_size_large: '大',
      ui_density: '界面密度',
      density_compact: '紧凑',
      density_comfortable: '舒适',
      density_spacious: '宽松',
      border_radius: '圆角大小',
      radius_none: '无',
      radius_small: '小',
      radius_medium: '中',
      radius_large: '大',
      animations: '动画效果',
      reset_defaults: '重置为默认'
    },
  },
};

export const i18n = createI18n({
  legacy: false,
  globalInjection: true,
  locale: navigator.language.toLowerCase().startsWith('zh') ? 'zh' : 'en',
  fallbackLocale: 'en',
  messages,
});


